/*
 * $Id: MapList.java,v 1.1 2007-01-29 17:00:56 klose Exp $
 */
package de.fanuffel.generic.functions;

import java.util.Collection;
import java.util.Vector;

public class MapList<A, B> implements
    Functor<A, B, Collection<A>, Collection<B>> {

  public Function<Collection<A>, Collection<B>> map(final Function<A, B> f) {
    return new Function<Collection<A>, Collection<B>>() {
      public Collection<B> eval(Collection<A> as) {
        Collection<B> bs = new Vector<B>();
        for (A a : as) {
          bs.add(f.eval(a));
        }
        return bs;
      }
    };
  }

}
